package org.shilong.logic.Json;

import java.util.Iterator;
import java.util.List;

import org.shilong.model.AccountModel;
import org.shilong.model.PartyCommentModel;

import com.url.ajax.json.JSONArray;
import com.url.ajax.json.JSONException;
import com.url.ajax.json.JSONObject;

public class QueryPartyComments4Json {

	private static List<PartyCommentModel> mList = null;

	private static String rlt = null;

	private static JSONObject jObject = null;

	private static JSONArray jArray = null;

	private static Iterator<PartyCommentModel> it = null;

	public static String getRlt( Object o_bject ){

		mList = null;

		rlt = null;

		mList = ( List<PartyCommentModel> )o_bject;

		it = mList.iterator();

		jObject = new JSONObject();

		jArray = new JSONArray();

		while( it.hasNext() ){
			PartyCommentModel bean = it.next();

			JSONObject oo = new JSONObject();

			try {
				oo.put( "account_name" , bean.getAccount_name() );
				oo.put( "comment", bean.getCOMMENT() );
				oo.put( "comment_time", bean.getComment_time() );

			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

			jArray.put( oo );
		}

		try {
			jObject.put( "rlt", jArray );
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		rlt = jObject.toString();

		return rlt;
	}
}
